<?php
	/**
	* @File name:	db.php
	* @Desription:	dbclass
	* @Author:	 	jinxin<jx@178.com>   
	* @Date:	 	Fri Jun 03 17:00:14 CST 2011
	* @Copyright 	Copytright (c) 2008-2011 178.COM Co., Ltd.
	* @version	 	$Id $
	*/
//	require_once('../configs/dbconf.php');
	require_once('_class.mysql.inc.php');
	class db {
		public static $dbs;
		public static function getInstence($dbName){
			if(!is_array(self::$dbs)) self::$dbs = array();
			if(array_key_exists($dbName, self::$dbs)){
				return self::$dbs[$dbName];
			}
			if(array_key_exists($dbName, $_SERVER['config']['db'])){
				$conf = $_SERVER['config']['db'][$dbName];
				if(!array_key_exists('type', $conf)){
					$conf['type'] = 'mysql';
				}
				self::$dbs[$dbName] = new MysqlDB($conf['host'],$conf['port'],$conf['username'],$conf['password'],$conf['database'],$conf['charset'],$conf['debug']);
				return self::$dbs[$dbName];
			}else{
				return null;
			}
		}
		
	}
	
//	$db = db::getInstence('admin');
//	$users  = $db->fetchRow("SELECT * FROM user");
//	print_r($users);
//	print_r($db);
